Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gammapy stat #318

Merged
merged 8 commits into from
Apr 3, 2020
Merged

Conversation

rlopezcoto
Copy link
Contributor

@rlopezcoto rlopezcoto commented Apr 2, 2020

Due to the new version of gammapy (v0.17), excess_matching_significance_on_off function disappeared and now it is substituted by the following lines

@rlopezcoto
Copy link
Contributor Author

tests will not pass until this is merged...

len(n_background) == n_bins_energy and
len(alpha) == n_bins_energy):
print("Excess, background and alpha arrays must have the same length")
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise ValueError with that message, not print and return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if any(len(a) != n_bins_energy for a in (n_excesses, n_background, alpha)) as a more concise formulation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, already implemented. The only problem with this (also present with my formulation) is that (n_excesses, n_background, alpha) must be input as lists/arrays, and an error is raised if only single floats are given as input

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then apply np.asanyarray(n_on, ndmin=1) to the input. If you also want to return a single number when the input were numbers, you can do sometehing like this:

scalar = np.isscalar(n_on)
n_on = np.asanyarray(n_on, ndmin=1)
n_off = ...
alpha = ...

...

if scalar:
     return result[0]
return result

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But let's get this merged first so the other PRs can run again

@maxnoe maxnoe merged commit 42258b5 into cta-observatory:master Apr 3, 2020
@rlopezcoto rlopezcoto deleted the update_gammapy_stat branch April 9, 2020 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants